package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.SubUseBrowseRequest;
import cn.stylefeng.guns.modular.business.service.SubUseBrowseService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 控制器
 *
 * @author zyw
 * @date 2021/08/17 15:39
 */

@RestController
@ApiResource(name="用户浏览记录controller")
public class SubUseBrowseController {

    @Resource
    private SubUseBrowseService subUseBrowseService;

    /**
     * 添加
     *
     * @author zyw
     * @date 2021/08/17 15:39
     */
    @PostResource(name = "添加", path = "/subUseBrowse/add")
    public ResponseData add(@RequestBody @Validated(SubUseBrowseRequest.add.class) SubUseBrowseRequest subUseBrowseRequest) {
        subUseBrowseService.add(subUseBrowseRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zyw
     * @date 2021/08/17 15:39
     */
    @PostResource(name = "删除", path = "/subUseBrowse/delete")
    public ResponseData delete(@RequestBody @Validated(SubUseBrowseRequest.delete.class) SubUseBrowseRequest subUseBrowseRequest) {
        subUseBrowseService.del(subUseBrowseRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zyw
     * @date 2021/08/17 15:39
     */
    @PostResource(name = "编辑", path = "/subUseBrowse/edit")
    public ResponseData edit(@RequestBody @Validated(SubUseBrowseRequest.edit.class) SubUseBrowseRequest subUseBrowseRequest) {
        subUseBrowseService.edit(subUseBrowseRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zyw
     * @date 2021/08/17 15:39
     */
    @GetResource(name = "查看详情", path = "/subUseBrowse/detail")
    public ResponseData detail(@Validated(SubUseBrowseRequest.detail.class) SubUseBrowseRequest subUseBrowseRequest) {
        return new SuccessResponseData(subUseBrowseService.detail(subUseBrowseRequest));
    }

    /**
     * 获取列表
     *
     * @author zyw
     * @date 2021/08/17 15:39
     */
    @GetResource(name = "获取列表", path = "/subUseBrowse/list")
    public ResponseData list(SubUseBrowseRequest subUseBrowseRequest) {
        return new SuccessResponseData(subUseBrowseService.findList(subUseBrowseRequest));
    }


    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/11/05 15:32
     */
    @GetResource(name = "分页查询", path = "/subUseBrowse/page")
    public ResponseData page(String title) {
        SubUseBrowseRequest subUseBrowseRequest = new SubUseBrowseRequest();
        subUseBrowseRequest.setBrowseTitle(title);
        return new SuccessResponseData(subUseBrowseService.findPage(subUseBrowseRequest));
    }

}